<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>个人资料</title>
    <style type="text/css">
        @import url(https://fonts.googleapis.com/css?family=Roboto:300);

        .login-page {
            width: 360px;
            padding: 8% 0 0;
            margin: auto;
        }

        .form {
            position: relative;
            z-index: 1;
            background: #FFFFFF;
            max-width: 360px;
            margin: 0 auto 100px;
            padding: 45px;
            text-align: center;
            box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
        }

        .form input, .form select {
            font-family: "Roboto", sans-serif;
            outline: 0;
            background: #f2f2f2;
            width: 100%;
            border: 0;
            margin: 0 0 15px;
            padding: 15px;
            box-sizing: border-box;
            font-size: 14px;
        }

        .form button {
            font-family: "Roboto", sans-serif;
            outline: 0;
            background: #5b5bf3;
            width: 100%;
            border: 0;
            padding: 15px;
            color: #FFFFFF;
            font-size: 14px;
            -webkit-transition: all 0.3s ease;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        .form button:hover, .form button:active, .form button:focus {
            background: red;
        }

        .form .message {
            margin: 15px 0 0;
            color: #b3b3b3;
            font-size: 12px;
        }

        .form .message a {
            color: #5b5bf3;
            text-decoration: none;
        }

        .form .register-form {
            display: none;
        }

        .container {
            position: relative;
            z-index: 1;
            max-width: 300px;
            margin: 0 auto;
        }

        .container:before, .container:after {
            content: "";
            display: block;
            clear: both;
        }

        .container .info {
            margin: 50px auto;
            text-align: center;
        }

        .container .info h1 {
            margin: 0 0 15px;
            padding: 0;
            font-size: 36px;
            font-weight: 300;
            color: #1a1a1a;
        }

        .container .info span {
            color: #4d4d4d;
            font-size: 12px;
        }

        .container .info span a {
            color: #000000;
            text-decoration: none;
        }

        .container .info span .fa {
            color: #EF3B3A;
        }

        body {
            background: #5b5bf3;
            background: -webkit-linear-gradient(right, #5b5bf3, #8DC26F);
            background: -moz-linear-gradient(right, #5b5bf3, #8DC26F);
            background: -o-linear-gradient(right, #5b5bf3, #8DC26F);
            background: linear-gradient(to left, #5b5bf3, #8DC26F);
            font-family: "Roboto", sans-serif;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
    </style>
    <style type="text/css">
        #popups-box {
            position: fixed;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.3);
            z-index: 2;
        }

        #popups-box > .popups-window {
            font-family: "Roboto", sans-serif;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #ffffff;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
        }

        #popups-box > .popups-window > .title {
            color: #FFFFFF;
            display: block;
            height: 38px;
            line-height: 38px;
            padding-left: 20px;
            font-size: 14px;
            border: 1px solid #5b5bf3;
            background-color: #5b5bf3;
        }

        #popups-box > .popups-window > .close {
            float: right;
            color: #FFFFFF;
            width: 40px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            text-decoration: none;
        }

        #popups-box > .popups-window > .close:hover {
            color: #CCCCCC;
        }
    </style>
    <style type="text/css">
        #user-from {

        }

        #user-from input {
            width: 180px;
            height: 40px;
            display: inline-block;
        }
    </style>
</head>
<body>

<div class="login-page">
    <div class="form">
        <span style="font-family: STHupo; font-size: 20px; color:#0F5F49;">个人资料</span>
        <form id="user-from" action="" method="post">
            <div>
                <input type="hidden" name="userId" th:value="${user.userId}">
                <label for="">账号：</label>
                <input type="text" name="account" required th:value="${user.account}">
            </div>
            <div>
                <label for="">密码：</label>
                <input type="password" required name="password" th:value="${user.password}">
            </div>
            <div>
                <label for="">手机：</label>
                <input type="text" name="mobile" required th:value="${user.mobile}">
            </div>
            <button type="submit">确定</button>
        </form>
    </div>
</div>

<div hidden id="popups-box">
    <div class="popups-window">
        <a class="close" href="#">X</a>
        <span class="title"></span>
        <div class="main" style="margin-left: 20px; margin-right: 20px;color: #3a4759;">
            <h2 style="margin-left: 20px; margin-right: 20px;color: #3a4759;">请稍后，数据加载中...</h2>
        </div>
    </div>
</div>
<script th:src="@{/static/js/jquery-3.6.0.js}" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        // 弹出窗口打开方法
        function openPopupsWindow(title) {
            $('#popups-box > .popups-window > .title').text(title);
            $('#popups-box > .popups-window > .close').click(function (e) {
                e.preventDefault();
                $('#popups-box').hide();
                window.location.reload();
            });
            $('#popups-box').show();
            return $('#popups-box > .popups-window > .main');
        }


        // 注册表单提交
        $("#user-from").submit(function (e) {
            let userId = $('#user-from input[name="userId"]').val();
            let account = $('#user-from input[name="account"]').val();
            let password = $('#user-from input[name="password"]').val();
            let mobile = $('#user-from input[name="mobile"]').val();

            let popupsWindow = openPopupsWindow('提示');
            $.ajax({
                url: 'edit',
                type: "POST",
                data: {
                    'userId': userId,
                    'account': account,
                    'password': password,
                    'mobile': mobile
                },
                success: function (res) {
                    popupsWindow.html(res);
                    if (res.indexOf('编辑成功！') != -1) {
                        window.setTimeout(function () {
                            window.location.href = 'index';
                        }, 1000);
                    }
                }
            });

            return false;
        });

    });
</script>
</body>
</html>
